using UnityEngine;
using System.Collections;

public class ThreadDemoTwo
{
    public Vector3 target;
    public bool run = true;
    System.Collections.Generic.Queue<float> xTrack;

    public ThreadDemoTwo()
    {
        xTrack = new System.Collections.Generic.Queue<float>();
    }

    public void Run()
    {
        while (run)
        {
            System.Threading.Thread.Sleep(500);
            xTrack.Enqueue(target.x);
            UnityEngine.Debug.Log("wrote value");
        }

        System.IO.StreamWriter write = new System.IO.StreamWriter("meep.txt");

        while (xTrack.Count > 0)
        {
            write.WriteLine(xTrack.Dequeue().ToString());
        }
        write.Close();
    }

}
